<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>个人社保计算器</title>
		<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
		<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
		<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
		<script>
			function calc(){
				// 取得工资文本框的数据
				sal = $("#salary").val();//"8000"
				salnum = parseInt(sal);//转换类型
				//开始计算
				ylgr = salnum * 0.08;
				ylgs = salnum * 0.02;
				//3.把计算的结果放到单元格里
				$("#ylgr").text(ylgr);
				$("#ylgs").text(ylgs);
				//医保
				ybgr = salnum * 0.02;
				ybgs = salnum * 0.06;				
				$("#ybgr").text(ybgr);
				$("#ybgs").text(ybgs);
				//失业
				sygr = salnum * 0.005;
				sygs = salnum * 0.015;				
				$("#sygr").text(sygr);
				$("#sygs").text(sygs);
				//工伤				
				gsgs = salnum * 0.005;		
				$("#gsgs").text(gsgs);
				//生育				
				sybx = salnum * 0.008;			
				$("#sybx").text(sybx);
				//公积金
				gjjgr = salnum * 0.12;
				gjjgs = salnum * 0.12;
				$("#gjjgr").text(gjjgr);
				$("#gjjgs").text(gjjgs);
			}
		</script>
	</head>
	
	<body>
		<div class= "container">
			<h1 class ="text-center">个人社保计算器</h1>
			<table class="table table-bordered">
				<tr>
					<td class="text-center">工资</td>
					<td colspan="3">
						<input id="salary" placeholder="请输入工资" class="form-control" type="text">
					</td>
					<td>
						<button onclick="calc()" class="btn btn-danger btn-block">计算</button>
					</td>
				</tr>
				<tr>
					<td class="text-center bg-primary">险种</td>
					<td class="text-center bg-primary">个人%</td>
					<td class="text-center bg-primary">个人</td>   
					<td class="text-center bg-primary">公司 %</td>
					<td class="text-center bg-primary">公司</td>
				</tr>
				<tr class= "text-center">
					<td>养老</td>
					<td>8%</td>
					<td id ="ylgr" ></td>
					<td>20%</td>
					<td id="ylgs"></td>
				</tr>
				<tr class="text-center">
					<td>医疗</td>
					<td>2%</td>
					<td id ="ybgr"></td>
					<td>6%</td>
					<td id= "ybgs"></td>
				</tr>
				<tr class="text-center">
					<td>失业</td>
					<td>0.5%</td>
					<td id="sygr"></td>
					<td>1.5%</td>
					<td id="sygs"></td>
				</tr>
				<tr class="text-center">
					<td>工伤</td>
					<td></td>
					<td></td>
					<td>0.5%</td>
					<td id ="gsgs"></td>
				</tr>
				<tr class="text-center">
					<td>生育</td>
					<td></td>
					<td></td>
					<td>0.8%</td>
					<td id="sybx"></td>
				</tr>
				<tr class="text-center">
					<td>公积金</td>
					<td>12%</td>
					<td id="gjjgr"></td>
					<td>12%</td>
					<td id="gjjgs"></td>
				</tr>
				<tr class="text-center">
					<td>合计</td>
					<td>个人合计</td>
					<td id="grhj"></td>
					<td>公司合计</td>
					<td id="gshj"></td>
				</tr>
				<tr class="text-center">
					<td>总额</td>
					<td colspan ="4"></td>
				</tr>
			</table>
			<div class="text-center">开发者：王大爷</div>
		</div>
	</body>
</html>
